//
//  OpinionViewController.m
//  TableViewGroup
//
//  Created by 侯振兴 on 15/1/6.
//  Copyright (c) 2015年 侯振兴. All rights reserved.
//

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#import "OpinionViewController.h"

@interface OpinionViewController ()

@end

@implementation OpinionViewController

- (void)dealloc
{
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
//    self.automaticallyAdjustsScrollViewInsets = NO;
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 150, SCREEN_WIDTH, SCREEN_HEIGHT - 264)];
    image.image = [UIImage imageNamed:@"wolfgang3.jpg"];
//    [image setFrame:CGRectMake(0, 200, SCREEN_WIDTH, SCREEN_HEIGHT - 200)];
    [self.view addSubview:image];
    self.navigationItem.title = @"意见反馈";
    [self createOpinion];
}


- (void)createOpinion
{
    self.field = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150)];
    _field.borderStyle = UITextBorderStyleRoundedRect;
    _field.placeholder = @"请输入反馈信息";

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2, 10, SCREEN_WIDTH / 7, 30)];
    [button setBackgroundColor:[UIColor clearColor]];
    [button setTitle:@"发送" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
    
    [self.view addSubview:_field];
    [self.view addSubview:button];
    [_field release];
    [button release];
}

- (void)buttonAction:(id)sender
{
    if ([_field.text isEqualToString:@""]) {
        self.bAlert = [[UIAlertView alloc] initWithTitle:@"信息不能为空的" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
        [_bAlert show];
        [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(timerAction:) userInfo:nil repeats:NO];
        [_bAlert release];
        
    } else {
    UIAlertView *aAlert = [[UIAlertView alloc] initWithTitle:@"嘟..嘟..嘟.." message:@"是否发送" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
    [aAlert show];
    [aAlert release];
    }
}

- (void)timerAction:(id)sender
{
    [_bAlert dismissWithClickedButtonIndex:0 animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
